#include <iostream>  
using namespace std;  
  
const int MAXN = 1005;  
  
int a[MAXN][MAXN], b[MAXN][MAXN], c[MAXN][MAXN];  
  
int main() {  
    int n;  
    cin >> n;  
    for (int i = 1; i <= n; i++) {  
        for (int j = 1; j <= n; j++) {  
            cin >> a[i][j];  
        }  
    }  
    for (int i = 1; i <= n; i++) {  
        for (int j = 1; j <= n; j++) {  
            cin >> b[i][j];  
        }  
    }  
  
    // 求两个对称矩阵之和  
    for (int i = 1; i <= n; i++) {  
        for (int j = 1; j <= n; j++) {  
            c[i][j] = a[i][j] + b[i][j];  
        }  
    }  
    cout << "矩阵之和为：" << endl;  
    for (int i = 1; i <= n; i++) {  
        for (int j = 1; j <= n; j++) {  
            cout << c[i][j] << " ";  
        }  
        cout << endl;  
    }  
  
    // 求两个对称矩阵的乘积  
    for (int i = 1; i <= n; i++) {  
        for (int j = 1; j <= n; j++) {  
            int sum = 0;  
            for (int k = 1; k <= n; k++) {  
                sum += a[i][k] * b[k][j];  
            }  
            c[i][j] = sum;  
        }  
    }  
    cout << "矩阵乘积为：" << endl;  
    for (int i = 1; i <= n; i++) {  
        for (int j = 1; j <= n; j++) {  
            cout << c[i][j] << " ";  
        }  
        cout << endl;  
    }  
  
    return 0;  
}